class_name PlayerLedgeClimbState
extends GameplayState

@onready var player: Player = $"../../../"

var animator_last_position: Vector2 = Vector2.ZERO

var offset: Vector2 = Vector2(12, -25)


func _on_enter() -> void:
	player.animator.play(&"ledge_climb")

	player.player_tag_manager.add_tag(player.player_tag_manager.State_Wall_Ledge_Climb)

	animator_last_position = player.animator.position


func _on_update(_delta: float) -> void:
	player.velocity = Vector2.ZERO

	if not player.animator.is_playing():
		get_parent().change_state("GhostState", func(): pass)
		return
	

func _on_exit() -> void:
	player.player_tag_manager.remove_tag(player.player_tag_manager.State_Wall_Ledge_Climb)
	
	player.global_position += Vector2(offset.x * player.face_direction, offset.y)
	player.animator.position = animator_last_position
